<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lzc="http://schemas.icitadel.com/Lazarus/Compiled.xsd" version="1.0">

	<xsl:output method="text"/>

	<xsl:include href="../../common.xsl" />
	<xsl:include href="../../convert.xsl" />

   <xsl:template match="lzc:project">
-- Project: <xsl:value-of select="@name" />
-- Table and Relationship creation scripts.
      
      <!-- Drop the tables -->
<xsl:text>-- Table Deletion

SET ANSI_NULLS ON 
GO

</xsl:text>

<xsl:for-each select="lzc:tables/lzc:table[ count( lzc:fields/lzc:field ) &gt; 0 ]">
	<xsl:variable name="TABLE_NAME">
		<xsl:text>tbl</xsl:text>
		<xsl:value-of select="@name" />
	</xsl:variable>
<xsl:text>
/*
Table Deletion -- </xsl:text><xsl:value-of select="@name" />
<xsl:if test="lzc:description"><xsl:text>

</xsl:text>
<xsl:value-of select="lzc:description" />
</xsl:if><xsl:text>
*/
IF ( EXISTS( SELECT syso.id FROM sysobjects syso WHERE syso.type = 'U' AND syso.name = '</xsl:text>
<xsl:value-of select="$TABLE_NAME" />
<xsl:text>' ) )
DROP TABLE </xsl:text><xsl:value-of select="ancestor::lzc:project/@owner" />.[<xsl:value-of select="$TABLE_NAME" />];
</xsl:for-each>
      
GO

SET ANSI_NULLS OFF
   </xsl:template>

</xsl:stylesheet>